//
//  SNOrderFormDetailBasicCell.m
//  app
//
//  Created by 王少宁 on 15/5/7.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//  配送时间,发票信息,买家留言 cell

#import "SNOrderFormDetailBasicCell.h"

@interface SNOrderFormDetailBasicCell ()
@property (nonatomic, retain) UILabel * leftLabel;
@property (nonatomic, retain) UILabel * rightLabel;
//@property (nonatomic, retain) UIImageView * rightImgView;
@property (nonatomic, retain) UIButton * mainBtn;
@end

@implementation SNOrderFormDetailBasicCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
    }
    return self;
}

- (void)createCell
{
//    _rightImgView = CREATE_WITH_FRAME_OF(UIImageView, CGPointMake(SCREEN_WIDTH - 25, (OrderFormDetailBasicCellHeight-20)*0.5),
//                                         [self.contentView.ubo ow:10 oh:20]);
//    _rightImgView.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"arrow_right@2x" ofType:@"png"]];
//    [self.contentView addSubview:_rightImgView];
    
    _rightLabel = CREATE_WITH_FRAME_OF(UILabel, [self.contentView.ufo ox:SCREEN_WIDTH-80 oy:0],
                                       [self.contentView.ubo ow:70 oh:kOrderFormDetailBasicCellHeight]);
    _rightLabel.textAlignment = NSTextAlignmentRight;
    _rightLabel.font = JKAppGlobleFontSmallTagText;
    _rightLabel.textColor = [XCommon hexStringToColor:kColor_s_light_gray_text];
    [self.contentView addSubview:_rightLabel];
    
    _leftLabel = CREATE_WITH_FRAME_OF(UILabel, CGPointMake(10, 0),
                                      [self.contentView.ubo ow:_rightLabel.ufo.x-20 oh:kOrderFormDetailBasicCellHeight]);
    _leftLabel.font = JKAppGlobleFontSmallTagText;
    _leftLabel.textColor = [XCommon hexStringToColor:kColor_l_light_gray_text];
    [self.contentView addSubview:_leftLabel];
    
    _mainBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _mainBtn.frame = CGRectMake(0, 0, SCREEN_WIDTH, kOrderFormDetailBasicCellHeight);
    [_mainBtn addTarget:self action:@selector(mainBtnClick:withEvent:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:_mainBtn];
}

- (void)cellWithModle:(SNOrderFormDetailBasicModel *)model row:(NSInteger)row invoiceInfo:(BOOL)invoiceInfo
{
    _leftLabel.text = model.notes;
    _rightLabel.text = model.buyerWordsStr;
}

- (void)mainBtnClick:(UIButton *)sender withEvent:(UIEvent*)event
{
    UITouch* touch = [[event allTouches] anyObject];
    
    if (touch.tapCount == 2) {
        if ([self.deletage respondsToSelector:@selector(orderFormDetailBasicCellClickWithRow:string:)]) {
            [self.deletage performSelector:@selector(orderFormDetailBasicCellClickWithRow:string:)withObject:[NSString stringWithFormat:@"%d",_mainBtn.tag] withObject:_leftLabel.text];
        }
    }
}

- (void)drawRect:(CGRect)rect
{
    [self drawTopLineLeft:UF(24) right:0 color:[XCommon hexStringToColor:kColor_s_separator_cell_line]];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
